﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

using GrimorioApplication.Localization;
using System.Windows.Media.Imaging;

namespace GrimorioApplication
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void btn_recipes_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/ListRecipes.xaml", UriKind.Relative));
        }

        private void btn_newrecipe_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/AddRecipePivot.xaml", UriKind.Relative));
        }

        private void btn_help_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/About.xaml", UriKind.Relative));
        }

        private void btn_search_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/SearchRecipe.xaml", UriKind.Relative));
        }
        
        // HANDLE TOUCH PRESS
        private void btn_recipes_Pressed(object sender, RoutedEventArgs e)
        {
            RecipeImage.Source = new BitmapImage(new Uri("/Img/AppIcons/recipe_100_100_INV.png", UriKind.RelativeOrAbsolute));
        }
        private void btn_help_Pressed(object sender, RoutedEventArgs e)
        {
            HelpImage.Source = new BitmapImage(new Uri("/Img/AppIcons/aboutHelp_100_100_INV.png", UriKind.RelativeOrAbsolute));
        }
        private void btn_search_Pressed(object sender, RoutedEventArgs e)
        {
            SearchImage.Source = new BitmapImage(new Uri("/Img/AppIcons/search_100_100_INV.png", UriKind.RelativeOrAbsolute));
        }
        private void btn_newrecipe_Pressed(object sender, RoutedEventArgs e)
        {
            AddImage.Source = new BitmapImage(new Uri("/Img/AppIcons/add_100_100_INV.png", UriKind.RelativeOrAbsolute));
        }

        // HANDLE TOUCH LEAVES
        private void btn_recipes_Leaves(object sender, RoutedEventArgs e)
        {
            RecipeImage.Source = new BitmapImage(new Uri("/Img/AppIcons/recipe_100_100.png", UriKind.RelativeOrAbsolute));
        }
        private void btn_help_Leaves(object sender, RoutedEventArgs e)
        {
            HelpImage.Source = new BitmapImage(new Uri("/Img/AppIcons/aboutHelp_100_100.png", UriKind.RelativeOrAbsolute));
        }
        private void btn_search_Leaves(object sender, RoutedEventArgs e)
        {
            SearchImage.Source = new BitmapImage(new Uri("/Img/AppIcons/search_100_100.png", UriKind.RelativeOrAbsolute));
        }
        private void btn_newrecipe_Leaves(object sender, RoutedEventArgs e)
        {
            AddImage.Source = new BitmapImage(new Uri("/Img/AppIcons/add_100_100.png", UriKind.RelativeOrAbsolute));
        }

        protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
        {
            App.ViewModel.SaveChangesToDB();
        }
    }
}